﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace idoshop {
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters) {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes) {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "", // URL with parameters
                new { controller = "Home", action = "Index" } // Parameter defaults
                );
            routes.MapRoute(
                "Products", // Route name
                "Products", // URL with parameters
                new { controller = "Home", action = "Products" } // Parameter defaults
                );
            routes.MapRoute(
                "ProductsDetails", // Route name
                "Products/{id}/{code}", // URL with parameters
                new { controller = "Home", action = "ProductDetails", code = UrlParameter.Optional } // Parameter defaults
                );
            routes.MapRoute(
                "News", // Route name
                "News", // URL with parameters
                new { controller = "Home", action = "News"} // Parameter defaults
                );
            routes.MapRoute(
                "NewsDetails", // Route name
                "News/{id}/{code}", // URL with parameters
                new { controller = "Home", action = "NewsDetails", code = UrlParameter.Optional } // Parameter defaults
                );
            routes.MapRoute(
                "About", // Route name
                "About", // URL with parameters
                new { controller = "Home", action = "About" } // Parameter defaults
                );
        }

        protected void Application_Start() {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}